package com.act.moudles.baseAct.entity;

import java.util.Date;

import com.act.utils.validations.AddGroup;
import com.act.utils.validations.UpdateGroup;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * 任务变量设置(TaskAnoVars)表实体类
 *
 * @author makejava
 * @since 2023-05-19 15:58:45
 */
@TableName("s_task_ano_vars")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class TaskAnoVars {

    /**
     * 主键
     */
    @TableId
    @NotNull(message = "主键不能为空",groups = UpdateGroup.class)
    private Long varId;

    /**
     * 节点Id
     */
    private Long anoId;

    /**
     * 变量名称
     */

    private String varName;

    /**
     * 变量key
     */
    @NotEmpty(message = "变量不能为空",groups = {AddGroup.class,UpdateGroup.class})
    private String varKey;

    /**
     * 备注
     */
    private String remark;

    /**
     * 创建者
     */
    private String createBy;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 变量
     */
    private String params;

    private Integer canEdit;

    private String varType;


    public LambdaQueryWrapper<TaskAnoVars> query(){
        LambdaQueryWrapper<TaskAnoVars> query = new LambdaQueryWrapper<>();
        query.eq(varId != null,TaskAnoVars::getVarId,varId);
        query.eq(anoId != null,TaskAnoVars::getAnoId,anoId);
        query.like(StringUtils.isNotEmpty(varName),TaskAnoVars::getVarName,varName);
        query.like(StringUtils.isNotEmpty(varKey),TaskAnoVars::getVarKey,varKey);
        return query;
    }

}

